package com.even.camerarecoder

import android.media.MediaCodec
import java.nio.ByteBuffer

class MuxerData(val isVideoData: Boolean, bufferSize: Int) {

    val byteBuffer: ByteBuffer =  ByteBuffer.allocateDirect(bufferSize)
    val bufferInfo: MediaCodec.BufferInfo = MediaCodec.BufferInfo()

    fun copyFrom(srcByteBuffer: ByteBuffer, srcBufferInfo: MediaCodec.BufferInfo) {
        srcByteBuffer.rewind()
        byteBuffer.clear()
        byteBuffer.put(srcByteBuffer)
        byteBuffer.flip()

        bufferInfo.set(
            srcBufferInfo.offset,
            srcBufferInfo.size,
            srcBufferInfo.presentationTimeUs,
            srcBufferInfo.flags
        )
    }

}